package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.Order;
import com.micro.modual.extension.OrderExtension;
import com.micro.modual.mapper.OrderMapper;
import com.micro.modual.model.bo.order.OrderBO;
import com.micro.modual.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>订单基础表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("orderService")
public class OrderServiceImpl extends AbstractBasicsServiceImpl<Order,Long> implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * <h2>新增订单基础表详情</h2>
     * @param orderBO {@link OrderBO} 订单基础表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addOrder(OrderBO orderBO) {
        Order order = OrderExtension.converAddOrder(orderBO);
        orderMapper.insertSelective(order);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改订单基础表详情</h2>
     * @param orderBO  {@link OrderBO} 订单基础表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editOrder(OrderBO orderBO) {
        Order order = OrderExtension.converEditOrder(orderBO);
        orderMapper.updateByPrimaryKeySelective(order);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除订单基础表信息</h2>
     * @param id  订单基础表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteOrder(Long id) {
        orderMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
